package com.ahcloud.edas.gatewaylog.biz.infrastructure.log.client;

import com.ahcloud.edas.gatewaylog.biz.application.helper.GatewayLogHelper;
import com.ahcloud.edas.gatewaylog.biz.application.service.GatewayLogService;
import com.ahcloud.edas.gatewaylog.biz.domain.log.dto.GatewayRequestLogDTO;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @program: ahcloud-operatelog
 * @description:
 * @author: YuKai Fan
 * @create: 2024/5/26 21:24
 **/
@Slf4j
public class DbLogCollectClient extends AbstractLogConsumeClient<GatewayRequestLogDTO> {

    public final GatewayLogService gatewayLogService;

    public DbLogCollectClient(GatewayLogService gatewayLogService) {
        this.gatewayLogService = gatewayLogService;
    }

    @Override
    public void consume0(List<GatewayRequestLogDTO> logs) throws Exception {
        gatewayLogService.saveBatch(GatewayLogHelper.convertList(logs));
    }

    @Override
    protected void initClient0() {
        log.warn("DbLogCollectClient initClient do nothing!");
    }

    @Override
    protected void close0() throws Exception {
        log.warn("DbLogCollectClient close do nothing!");
    }
}
